<?php

class Commonlibrary extends CI_Model{

  public function get_pax_count_for($pax)
  {
  	$count = -1;
  	switch ($pax) {
		case 'CIP':
  		case 'ADT':
			$count = $this->session->userdata('search_form_adults');
			break;
		case 'CNNCI':
		case 'CNN':
			$count = $this->session->userdata('search_form_children');
			break;
		case 'ZS':
			$count = $this->session->userdata('search_form_students');
			break;
		case 'CD':
			$count = $this->session->userdata('search_form_elders');
			break;
		case 'INF':
			$count = $this->session->userdata('search_form_infants');
			break;
		case 'MM':
			$count = $this->session->userdata('search_form_military');
			break;
	}
  	return $count;
  }
  public function format_flighttime($flight)
  {
    return substr($flight,-4,2) .':'. substr($flight,-2);
  }
  public function get_tax($tax_code)
  {
    return $this->taxes[$tax_code];
  }
  public function get_port_name($portCode)
  {
     return $this->portlist[$portCode];
  }
  /*
   * Covert the date format from dd.mm.yy to ddmmyy 
   */
  public function get_date_for_wd($date_string) {
    $parts = explode('.',$date_string);
    if (count($parts) == 3)
    {
      return $parts[0].$parts[1].$parts[2];
    }
    return $date_string;
  }
  public function get_port_code($value) {
    //$value = substr($value, strlen($value)-4, 3);
    $value = substr($value,0, 3);
    return $value;
  }
  public function to_en_upper($string) {
  	$translate = array(
    'ğ'=>'G', 'ü'=>'U', 'ş'=>'S', 'i'=>'I', 'ö'=>'O', 'ç'=>'C','ı'=>'I',
  	'Ğ'=>'G', 'Ü'=>'U', 'Ş'=>'S', 'İ'=>'I', 'Ö'=>'O', 'Ç'=>'C',
    );
  	$str = strtr($string,$translate);
  	return strtoupper($str);  
  }  
  
  
  public $cabin_types = array('C'=>'C','D'=>'C','J'=>'C','U'=>'Y*','O'=>'Y*','G'=>'Y*','P'=>'Y*'); // KALANLAR ECO
  public function get_cabin_type($cabin_type)
  {
    if (array_key_exists((string)$cabin_type,$this->cabin_types))  {
      return $this->cabin_types[(string)$cabin_type];
    } else {
      return 'Y';
    }
  } 
  
  public $taxes = array('YR'=>25);
  
  public $portlist= array(
    'ADA'=>'Adana',
    'ADF'=>'Adıyaman',
    'AJI'=>'Ağrı',
    'MZH'=>'Amasya/Merzifon',
    'ESB'=>'Ankara',
    'ANK'=>'Ankara',
    'AYT'=>'Antalya',
    'BAL'=>'Batman',
    'BJV'=>'Bodrum',
    'YEI'=>'Bursa',
    'CKZ'=>'Çanakkale',
    'TEQ'=>'Çorlu',
    'DLM'=>'Dalaman',
    'DNZ'=>'Denizli',
    'DIY'=>'Diyarbakır',
    'EZS'=>'Elazığ',
    'ERC'=>'Erzincan',
    'ERZ'=>'Erzurum',
    'AOE'=>'Eskişehir',
    'GZT'=>'Gaziantep',
    'HTY'=>'Hatay',
    'XHQ'=>'Hopa',
    'ISE'=>'Isparta',
    'IST'=>'Istanbul Atatürk Hav.',
    'SAW'=>'Istanbul Sabiha Gökçen',
    'ADB'=>'Izmir',
    'IZM'=>'Izmir',
    'KCM'=>'Kahramanmaraş',
    'KSY'=>'Kars',
    'ASR'=>'Kayseri',
    'ECN'=>'Kırbıs Ercan',
    'KYA'=>'Konya',
    'MLX'=>'Malatya',
    'MQM'=>'Mardin',
    'MSR'=>'Muş',
    'NAV'=>'Nevşehir',
    'SZF'=>'Samsun',
    'SIC'=>'Sinop',
    'VAS'=>'Sivas',
    'SFQ'=>'Şanlıurfa',
    'GNY'=>'Şanlıurfa (G.A.)',
    'TZX'=>'Trabzon',
    'USQ'=>'Uşak',
    'VAN'=>'Van',
    'TEQ'=>'Tekirdağ',
    'EDO'=>'Edremit',
    'GZP'=>'Gazipaşa',
    'ONQ'=>'Zonguldak',
    'SXZ'=>'Siirt',
    'TJK'=>'Tokat'
  );  
}

/* End of file Someclass.php */